﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel; 
using CourseArraging.Common;
using System.Drawing;
using CourseArraging.Properties;

namespace CourseArraging.Frm.jcxx
{
    /// <summary>
    /// 版权所有
    /// 石世特@温州医学院 sst330381@gmail.com
    /// </summary> 
    public class FrmUserInfo : Form
    {
        // Fields
        private IContainer components = null;
        private GroupBox groupBox1;
        private static FrmUserInfo instance;
        private Label label_address;
        private Label label_identify;
        private Label label_name;
        private Label label_no;
        private Label label_phone;
        private Label label_right;
        private Label label_sex;
        private Label label_spell;
        private Label label1;
        private Label label2;
        private Label label3;
        private Label label4;
        private Label label5;
        private Label label6;
        private Label label7;
        private Label label8;
        private ToolStrip toolStrip1;
        private ToolStripButton tsb_psw;
        private ToolStripButton tsb_sure;
        private ToolStripTextBox tsbox_new;
        private ToolStripTextBox tsbox_old;
        private ToolStripLabel tslabel_psw_new;
        private ToolStripLabel tslabel_psw_old;
        private YhxxService.YhxxServiceClient yhxxdao = new YhxxService.YhxxServiceClient();

        // Methods
        public FrmUserInfo()
        {
            this.InitializeComponent();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void FrmUserInfo_Load(object sender, EventArgs e)
        {
            this.showIcon(false);
            this.showInfo();
        }

        public static FrmUserInfo GetInstance()
        {
            if ((instance == null) || instance.IsDisposed)
            {
                instance = new FrmUserInfo();
                instance.MdiParent = GlobalVar.frmMain;
            }
            instance.BringToFront();
            return instance;
        }

        private void InitializeComponent()
        {
            this.groupBox1 = new GroupBox();
            this.label1 = new Label();
            this.label2 = new Label();
            this.label3 = new Label();
            this.label4 = new Label();
            this.label5 = new Label();
            this.label6 = new Label();
            this.label7 = new Label();
            this.label8 = new Label();
            this.label_right = new Label();
            this.label_identify = new Label();
            this.label_address = new Label();
            this.label_phone = new Label();
            this.label_sex = new Label();
            this.label_spell = new Label();
            this.label_name = new Label();
            this.label_no = new Label();
            this.toolStrip1 = new ToolStrip();
            this.tsb_psw = new ToolStripButton();
            this.tsb_sure = new ToolStripButton();
            this.tslabel_psw_old = new ToolStripLabel();
            this.tsbox_old = new ToolStripTextBox();
            this.tslabel_psw_new = new ToolStripLabel();
            this.tsbox_new = new ToolStripTextBox();
            this.groupBox1.SuspendLayout();
            this.toolStrip1.SuspendLayout();
            base.SuspendLayout();
            this.groupBox1.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.groupBox1.Controls.Add(this.label_right);
            this.groupBox1.Controls.Add(this.label_identify);
            this.groupBox1.Controls.Add(this.label_address);
            this.groupBox1.Controls.Add(this.label_phone);
            this.groupBox1.Controls.Add(this.label_sex);
            this.groupBox1.Controls.Add(this.label_spell);
            this.groupBox1.Controls.Add(this.label_name);
            this.groupBox1.Controls.Add(this.label_no);
            this.groupBox1.Controls.Add(this.label8);
            this.groupBox1.Controls.Add(this.label7);
            this.groupBox1.Controls.Add(this.label6);
            this.groupBox1.Controls.Add(this.label5);
            this.groupBox1.Controls.Add(this.label4);
            this.groupBox1.Controls.Add(this.label3);
            this.groupBox1.Controls.Add(this.label2);
            this.groupBox1.Controls.Add(this.label1);
            this.groupBox1.Font = new Font("微软雅黑", 12f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
            this.groupBox1.Location = new Point(12, 0x22);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new Size(0x220, 0xb1);
            this.groupBox1.TabIndex = 0;
            this.groupBox1.TabStop = false;
            this.label1.AutoSize = true;
            this.label1.Font = new Font("微软雅黑", 12f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
            this.label1.Location = new Point(0x13, 0x17);
            this.label1.Name = "label1";
            this.label1.Size = new Size(0x38, 0x15);
            this.label1.TabIndex = 0;
            this.label1.Text = "编  号:";
            this.label2.AutoSize = true;
            this.label2.Font = new Font("微软雅黑", 12f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
            this.label2.Location = new Point(0x13, 0x37);
            this.label2.Name = "label2";
            this.label2.Size = new Size(0x38, 0x15);
            this.label2.TabIndex = 2;
            this.label2.Text = "姓  名:";
            this.label3.AutoSize = true;
            this.label3.Font = new Font("微软雅黑", 12f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
            this.label3.Location = new Point(0x13, 90);
            this.label3.Name = "label3";
            this.label3.Size = new Size(0x38, 0x15);
            this.label3.TabIndex = 4;
            this.label3.Text = "简  拼:";
            this.label4.AutoSize = true;
            this.label4.Font = new Font("微软雅黑", 12f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
            this.label4.Location = new Point(0x13, 0x7d);
            this.label4.Name = "label4";
            this.label4.Size = new Size(0x38, 0x15);
            this.label4.TabIndex = 6;
            this.label4.Text = "性  别:";
            this.label5.AutoSize = true;
            this.label5.Font = new Font("微软雅黑", 12f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
            this.label5.Location = new Point(0x105, 0x17);
            this.label5.Name = "label5";
            this.label5.Size = new Size(0x38, 0x15);
            this.label5.TabIndex = 8;
            this.label5.Text = "电  话:";
            this.label6.AutoSize = true;
            this.label6.Font = new Font("微软雅黑", 12f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
            this.label6.Location = new Point(0x105, 0x3a);
            this.label6.Name = "label6";
            this.label6.Size = new Size(0x38, 0x15);
            this.label6.TabIndex = 10;
            this.label6.Text = "地  址:";
            this.label7.AutoSize = true;
            this.label7.Font = new Font("微软雅黑", 12f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
            this.label7.Location = new Point(0x105, 0x5d);
            this.label7.Name = "label7";
            this.label7.Size = new Size(0x3e, 0x15);
            this.label7.TabIndex = 12;
            this.label7.Text = "身份证:";
            this.label8.AutoSize = true;
            this.label8.Font = new Font("微软雅黑", 12f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
            this.label8.Location = new Point(0x105, 0x80);
            this.label8.Name = "label8";
            this.label8.Size = new Size(0x38, 0x15);
            this.label8.TabIndex = 14;
            this.label8.Text = "权  限:";
            this.label_right.AutoSize = true;
            this.label_right.Font = new Font("微软雅黑", 12f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
            this.label_right.Location = new Point(350, 130);
            this.label_right.Name = "label_right";
            this.label_right.Size = new Size(0x2e, 0x15);
            this.label_right.TabIndex = 0x16;
            this.label_right.Text = "权限:";
            this.label_identify.AutoSize = true;
            this.label_identify.Font = new Font("微软雅黑", 12f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
            this.label_identify.Location = new Point(350, 0x5f);
            this.label_identify.Name = "label_identify";
            this.label_identify.Size = new Size(0x3e, 0x15);
            this.label_identify.TabIndex = 0x15;
            this.label_identify.Text = "身份证:";
            this.label_address.AutoSize = true;
            this.label_address.Font = new Font("微软雅黑", 12f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
            this.label_address.Location = new Point(350, 60);
            this.label_address.Name = "label_address";
            this.label_address.Size = new Size(0x2e, 0x15);
            this.label_address.TabIndex = 20;
            this.label_address.Text = "地址:";
            this.label_phone.AutoSize = true;
            this.label_phone.Font = new Font("微软雅黑", 12f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
            this.label_phone.Location = new Point(350, 0x19);
            this.label_phone.Name = "label_phone";
            this.label_phone.Size = new Size(0x2e, 0x15);
            this.label_phone.TabIndex = 0x13;
            this.label_phone.Text = "电话:";
            this.label_sex.AutoSize = true;
            this.label_sex.Font = new Font("微软雅黑", 12f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
            this.label_sex.Location = new Point(0x6c, 0x7f);
            this.label_sex.Name = "label_sex";
            this.label_sex.Size = new Size(0x2e, 0x15);
            this.label_sex.TabIndex = 0x12;
            this.label_sex.Text = "性别:";
            this.label_spell.AutoSize = true;
            this.label_spell.Font = new Font("微软雅黑", 12f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
            this.label_spell.Location = new Point(0x6c, 0x5c);
            this.label_spell.Name = "label_spell";
            this.label_spell.Size = new Size(0x2e, 0x15);
            this.label_spell.TabIndex = 0x11;
            this.label_spell.Text = "简拼:";
            this.label_name.AutoSize = true;
            this.label_name.Font = new Font("微软雅黑", 12f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
            this.label_name.Location = new Point(0x6c, 0x39);
            this.label_name.Name = "label_name";
            this.label_name.Size = new Size(0x2e, 0x15);
            this.label_name.TabIndex = 0x10;
            this.label_name.Text = "姓名:";
            this.label_no.AutoSize = true;
            this.label_no.Font = new Font("微软雅黑", 12f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
            this.label_no.Location = new Point(0x6c, 0x19);
            this.label_no.Name = "label_no";
            this.label_no.Size = new Size(0x2e, 0x15);
            this.label_no.TabIndex = 15;
            this.label_no.Text = "编号:";
            this.toolStrip1.ImageScalingSize = new Size(0x18, 0x18);
            this.toolStrip1.Items.AddRange(new ToolStripItem[] { this.tsb_psw, this.tslabel_psw_old, this.tsbox_old, this.tslabel_psw_new, this.tsbox_new, this.tsb_sure });
            this.toolStrip1.Location = new Point(0, 0);
            this.toolStrip1.Name = "toolStrip1";
            this.toolStrip1.Size = new Size(0x238, 0x1f);
            this.toolStrip1.TabIndex = 1;
            this.toolStrip1.Text = "toolStrip1";
            this.tsb_psw.Image = Resources._1294395280_system_lock_screen;
            this.tsb_psw.ImageTransparentColor = Color.Magenta;
            this.tsb_psw.Name = "tsb_psw";
            this.tsb_psw.Size = new Size(0x54, 0x1c);
            this.tsb_psw.Text = "修改密码";
            this.tsb_psw.Click += new EventHandler(this.tsb_psw_Click);
            this.tsb_sure.Image = Resources._1294462998_clean;
            this.tsb_sure.ImageTransparentColor = Color.Magenta;
            this.tsb_sure.Name = "tsb_sure";
            this.tsb_sure.Size = new Size(60, 0x1c);
            this.tsb_sure.Text = "确定";
            this.tsb_sure.Click += new EventHandler(this.tsb_sure_Click);
            this.tslabel_psw_old.Image = Resources._1294395280_system_lock_screen;
            this.tslabel_psw_old.Name = "tslabel_psw_old";
            this.tslabel_psw_old.Size = new Size(0x44, 0x1c);
            this.tslabel_psw_old.Text = "原密码";
            this.tsbox_old.Name = "tsbox_old";
            this.tsbox_old.Size = new Size(100, 0x1f);
            this.tslabel_psw_new.Name = "tslabel_psw_new";
            this.tslabel_psw_new.Size = new Size(0x2c, 0x1c);
            this.tslabel_psw_new.Text = "新密码";
            this.tsbox_new.Name = "tsbox_new";
            this.tsbox_new.Size = new Size(100, 0x1f);
            base.AutoScaleDimensions = new SizeF(6f, 12f);
//            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x238, 0xe1);
            base.Controls.Add(this.toolStrip1);
            base.Controls.Add(this.groupBox1);
            base.Name = "FrmUserInfo";
            this.Text = "个人信息";
            base.Load += new EventHandler(this.FrmUserInfo_Load);
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.toolStrip1.ResumeLayout(false);
            this.toolStrip1.PerformLayout();
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        public void showIcon(bool showOrHide)
        {
            this.tslabel_psw_new.Visible = showOrHide;
            this.tslabel_psw_old.Visible = showOrHide;
            this.tsbox_new.Visible = showOrHide;
            this.tsbox_old.Visible = showOrHide;
            this.tsb_sure.Visible = showOrHide;
        }

        public void showInfo()
        {
            this.label_identify.Text = GlobalVar.yhEntity.user_id.ToString();
            this.label_name.Text = GlobalVar.yhEntity.user_name;
            this.label_spell.Text = GlobalVar.yhEntity.user_spell;
            this.label_sex.Text = GlobalVar.yhEntity.user_sex;
            this.label_phone.Text = GlobalVar.yhEntity.user_phone;
            this.label_address.Text = GlobalVar.yhEntity.user_address;
            this.label_identify.Text = GlobalVar.yhEntity.user_identify;
            this.label_right.Text = GlobalVar.yhEntity.user_right;
            this.label_no.Text = GlobalVar.yhEntity.user_no;
        }

        private void tsb_psw_Click(object sender, EventArgs e)
        {
            this.tsb_psw.Visible = false;
            this.showIcon(true);
        }

        private void tsb_sure_Click(object sender, EventArgs e)
        {
            if (this.tsbox_old.Text.Trim() == string.Empty)
            {
                MessageBox.Show("请输入旧密码!");
            }
            else if (this.tsbox_new.Text.Trim() == string.Empty)
            {
                MessageBox.Show("请输入新密码!");
            }
            else
            {
                if (this.tsbox_old.Text.Trim() == GlobalVar.yhEntity.user_psw)
                {
                    try
                    {
                        this.yhxxdao.ModiPsw8id(GlobalVar.yhEntity.user_id, this.tsbox_new.Text.Trim());
                        this.tsbox_new.Text = string.Empty;
                        this.tsbox_old.Text = string.Empty;
                        MessageBox.Show("密码修改成功!", "成功");
                    }
                    catch (Exception exception)
                    {
                        MessageBox.Show(exception.ToString(), "失败");
                    }
                }
                else
                {
                    MessageBox.Show("输入的密码错误, 无法修改! ", "失败");
                }
                this.tsb_psw.Visible = true;
                this.showIcon(false);
            }
        }
    }

 

}
